﻿<Window x:Class="ResourceBlender_Express.WinGenerate"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:loc="clr-namespace:ResourceBlender_Express"
    xmlns:validators="clr-namespace:ResourceBlender_Express.Validators"
    xmlns:props="clr-namespace:ResourceBlender_Express.Properties"
    loc:WindowService.EscapeClosesWindow="True"
    Title="Generate Resources"
    MinHeight="450" Height="470" MinWidth="400" Width="500" SizeToContent="WidthAndHeight"
    Loaded="Window_Loaded"
    WindowStartupLocation="CenterOwner"
    Style="{StaticResource {x:Type Window}}" Icon="/ResourceBlender-Express;component/Resources/images/resourceblender.ico">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.SaveAs" Executed="BrowseForFile" />
        <CommandBinding Command="loc:ResourceBlenderCommands.GenerateResources" Executed="GenerateResourcesHandler" />
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow" />
        <CommandBinding Command="loc:ResourceBlenderCommands.UpdateFilename" Executed="UpdateFilenameHandler" />
    </Window.CommandBindings>
    <Window.Resources>
        <ResourceDictionary>
            <props:Settings x:Key="settings" />
        </ResourceDictionary>
    </Window.Resources>
    <DockPanel>
        <Grid DockPanel.Dock="Top" Margin="6" DataContext="{StaticResource settings}">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <GroupBox Grid.Row="0" Grid.Column="0" Header="Select Components" MinHeight="100">
                <loc:ApplicationSelector x:Name="applicationSelector" SelectionChanged="TriggerUpdateFilename" />
            </GroupBox>

            <GroupBox Grid.Row="1" Grid.Column="0" Header="Options">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>

                    <Label Grid.Row="0" Grid.Column="0">Completion Threshold (Percent)</Label>
                    <TextBox Grid.Row="0" Grid.Column="1" x:Name="txtThreshold">
                        <Binding Path="Default.DefaultThreshold" Mode="TwoWay">
                            <Binding.ValidationRules>
                                <validators:IntegerRangeValidationRule
                                        MinValue="0"
                                        MaxValue="100"
                                        IsGeneric="False" />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox>
                    <CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="chkIncludeSummary" Margin="2"
                              IsChecked="{Binding Path=Default.IncludeSummary,Mode=TwoWay}">
                        Include Summary
                    </CheckBox>
                    <CheckBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name="chkZipOutput" Margin="2"
                              IsChecked="{Binding Path=Default.ZipOutput,Mode=TwoWay}" Checked="TriggerUpdateFilename" Unchecked="TriggerUpdateFilename">
                        Zip Output
                    </CheckBox>
                </Grid>
            </GroupBox>
            <GroupBox Grid.Row="2" Grid.Column="0" Header="Output Format">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" MaxWidth="350" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>

                    <ListBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" x:Name="lstFormat" Style="{StaticResource RadioListTemplate}"
                             ItemsSource="{Binding}" SelectedValuePath="Value" DisplayMemberPath="Key" MinHeight="120">
                    </ListBox>
                    <Label Grid.Row="1" Grid.Column="0">Output file</Label>
                    <TextBox Grid.Row="1" Grid.Column="1" x:Name="txtOutputPath">
                        <Binding Path="RelativeSource Self" Mode="Default">
                            <Binding.ValidationRules>
                                <validators:StringValidationRule
                                        MinimumLength="4"
                                        ErrorMessage="The output filename must be entered" />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox>
                    <Button Grid.Row="1" Grid.Column="2" Command="ApplicationCommands.SaveAs">Browse...</Button>
                </Grid>
            </GroupBox>

            <Grid Grid.Row="3" Grid.Column="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Button Grid.Column="2" MinWidth="140" Command="loc:ResourceBlenderCommands.GenerateResources" IsDefault="True">Generate Resources</Button>
                <Button Grid.Column="3" MinWidth="70" Command="ApplicationCommands.Close" IsCancel="True">Cancel</Button>
            </Grid>
        </Grid>
        <StatusBar DockPanel.Dock="Bottom" Height="24">
            <StatusBarItem x:Name="lblStatus" Visibility="Hidden">Loading</StatusBarItem>
            <StatusBarItem><ProgressBar x:Name="prgStatus" IsIndeterminate="True" /></StatusBarItem>
        </StatusBar>
    </DockPanel>
</Window>
